﻿/*
jquery.loading.js for the Dot Net Nuke Ajax Search Module Copyright (C) 2011  Jaime Alberto 
Jaramillo Zapata. (@g4m30n, peleleman@msn.com, jjaramillo@paradigmasolutions.com). This javascript
function defines a plugin that adds a small overlay to the caller with a small loading image.
     
This program is free software: you can redistribute it and/or modify it under the terms of the 
GNU General Public License as published by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License  along with this program.  If not, see http://www.gnu.org/licenses/.
*/
jQuery.fn.ShowLoadingOverlap = function (options) {
    var result = new Array();
    this.each(function () {
        var html = $('<div style="position: absolute; filter: alpha(opacity=50); opacity: .5; background-color:white; display:none;"><img src="DesktopModules/AjaxSearch/Img/ajax-loader.gif" style="width:31px; height:31px; display:block;"/></div>');
        var elementToOverlap = $(this);
        var image = html.find('img');
        var topMargin = (elementToOverlap.height() / 2);
        var topOffset = elementToOverlap.position().top;

        image.css('margin', topMargin + 'px' + ' auto');

        html.width(elementToOverlap.width());
        html.height(elementToOverlap.height());
        html.css('z-index', 999);
        html.css('top', topOffset);

        elementToOverlap.after(html);
        html.fadeIn('slow');
        result.push(html);
    });
    return result;
};